<?php
	//AYARLAR KISMI
	$cekilecek_text="http://plugins.diviksfilm.com/lisans.txt"; //bir sunucuya yüklediðiniz lisanslanmasýna izin veridðiniz alan adlarýnýn olduðu text dosyasý, tavsiyem googlepages.com gibi 24 saat açýk olmasýna güvenilir bir sunucuya yüklemenizdir
	//AYARLAR KISMI BÝTTÝ

	//NE YAPTIÐINIZI BÝLMÝYORSANIZ AÞAÐISINA DOKANMAYIN
	if (!function_exists("file")) { die("<strong><a href='http://www.php.net/file'>file</a></strong> fonksiyonu sunucuda yüklü olmalýdýr<br /> fonction <strong><a href='http://www.php.net/file'>file</a></strong> must be installed on the server"); } //file fonksiyonu yüklü deðilse lisans scripti çalýþmaz :)
	function soullisanskontrol() {
		if (substr($_SERVER['HTTP_HOST'], 0, 4) == "www.") { //alan adý deðiþkeni bazý sunucularda www ile baþlýyor bazýlarýnda www. suz ondan böyle bir deðiþkene ihtiyac var
		$domainadi = substr($_SERVER['HTTP_HOST'], 4);
		} else {
		$domainadi = $_SERVER['HTTP_HOST'];
		}
	return $domainadi;
	}
	$alanadi=soullisanskontrol();//yormasýn her seferinde 1 kez buffera alalým yeter

	$lisanstext=file($cekilecek_text,FILE_IGNORE_NEW_LINES); //yüklediðiniz text dosyasýnýn adresi
	$lisans=array();//boþ dizi oluþturduk önce yeni oluþacak kontrol dizisi için


	foreach($lisanstext as $sayi => $cekveri) {
	$lisans[$sayi]=rtrim($cekveri,"\r\n"); //bazen windows tabanlý metin editörlerinde yazýlan metinler ve linux üzerindeki editörelerde yazýlan metinlerinm sonundaki yeni satýra geçme kodlarý ayný olamayabiliyor. bu sebeple iþi saðlama alýp onlarýn temizlendiði yeni bir dizi oluþturuyoruzs
	}

	if (!in_array($alanadi,$lisans)) { 
	die("Lisanssýz Kullaným: ".$alanadi."<br /> Unlicensed Usage ".$alanadi); exit; //alan adý bizim dizimizde yoksa die() fonksiyonu ile siteyi kilitliyor, buraya kendi fonksiyonunuzu/nasýl çalýþacaðýný yazabilirsiniz
	}
	// ##################### DEFINE IMPORTANT CONSTANTS #######################
	// change the line below to the actual filename without ".php" extention.
	// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.

	define('THIS_SCRIPT', 'imdb');

	// #################### PRE-CACHE TEMPLATES AND DATA ######################
	// get special phrase groups
	$phrasegroups = array();

	// get special data templates from the datastore
	$specialtemplates = array();

	// pre-cache templates used by all actions
	$globaltemplates = array(
	// change the lines below to the list of actual templates used in the script
	'imdb',
	);

	// pre-cache templates used by specific actions
	$actiontemplates = array();

	// ########################## REQUIRE BACK-END ############################
	require_once('./global.php');
	require ("imdb/imdb.class.php");
	// #################### HARD CODE JAVASCRIPT PATHS ########################
	$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);

	// ########################################################################
	// ######################### START MAIN SCRIPT ############################
	// ########################################################################

	$q_text = "SELECT id FROM `" . TABLE_PREFIX . "imdb_sql` WHERE imdbid = ".$_GET['mid'];
	$q_result = $vbulletin->db->query_read($q_text);
	$row_array = $vbulletin->db->fetch_array($q_result);

	$id = $row_array['id'];



	if ($id <> '')
	{
		$q_text = "SELECT * FROM `" . TABLE_PREFIX . "imdb_sql` WHERE id = ".$id;
		$q_result = $vbulletin->db->query_read($q_text);
		$row_array = $vbulletin->db->fetch_array($q_result);

		$movie_photo 		.= $row_array['veri_resim'];
	    $movie_name 		.= $row_array['veri_film_adi'];
		$cast_photo 		.= $row_array['cast_photo'];
		$movie_yonetmen 	.= $row_array['veri_yonetmen'];
		$movie_genre 		.= $row_array['veri_film_turu'];
		$movie_yil 			.= $row_array['veri_yapim_yili'];
		$movie_time 		.= $row_array['veri_sure'];
		$movie_puan 		.= $row_array['veri_puan'];
		$movie_vote 		.= $row_array['movie_vote'];
		$movie_dil 			.= $row_array['veri_lisan'];
		$movie_ulke 		.= $row_array['veri_ulke'];
		$movie_oyuncular 	.= $row_array['veri_oyuncular'];
		$movie_konu 		.= $row_array['veri_aciklama'];
		$movie_yazar 		.= $row_array['veri_yazar'];
		$movie_yapimci 		.= $row_array['veri_yapimci'];
		$movie_muzik 		.= $row_array['veri_muzik'];
	}else {
		$git = "http://www.imdb.com/title/tt".$_GET[mid];
		$oIMDB = new IMDB($git);
		$movie_photo = str_replace("'", "\'", $oIMDB->getPoster());
	    $movie_name = str_replace("'", "\'", $oIMDB->getTitle());
	    $movie_yonetmen = str_replace("'", "\'", $oIMDB->getDirector());
	    $movie_genre = str_replace("'", "\'", $oIMDB->getGenre());
	    $movie_yil = str_replace("'", "\'", $oIMDB->getYear());
	    $movie_time = str_replace("'", "\'", $oIMDB->getRuntime());
	    $movie_puan = str_replace("'", "\'", $oIMDB->getRating());
		$movie_vote = str_replace("'","\'", $oIMDB->getVotes());
	    $movie_dil = str_replace("'", "\'", $oIMDB->getLanguages());
	    $movie_ulke = str_replace("'", "\'", $oIMDB->getCountry());
	    $movie_oyuncular = str_replace("'", "\'", $oIMDB->getCast(5));
	    $movie_konu = str_replace("'", "\'", $oIMDB->getPlot(350));
		$movie_yazar = str_replace("'", "\'", $oIMDB->getWriter());
		$movie_yapimci = str_replace("'", "\'", $oIMDB->getBudget());
		$movie_muzik = str_replace("'", "\'", $oIMDB->getReleaseDate());

		$query_txt = "INSERT IGNORE INTO  `" . TABLE_PREFIX . "imdb_sql` (imdbid, veri_resim, veri_film_adi, veri_yonetmen, veri_film_turu, veri_yapim_yili, veri_sure, veri_puan, movie_vote, veri_lisan, veri_ulke, veri_oyuncular, cast_photo, veri_aciklama,veri_yazar, veri_yapimci, veri_muzik) VALUES('$_GET[mid]', '$movie_photo', '$movie_name', '$movie_yonetmen', '$movie_genre', '$movie_yil', '$movie_time', '$movie_puan', '$movie_vote', '$movie_dil', '$movie_ulke', '$movie_oyuncular', '$cast_photo', '$movie_konu','$movie_yazar','$movie_yapimci','$movie_muzik')";

	      $db->query_write($query_txt);
	}
	